import Vue from 'vue'
import Router from 'vue-router'
import Layout from './views/layout/Layout'
import Login from './views/account/login.vue'
import NotFound from './views/404.vue'
import CourseList from './views/course/index.vue'
import CourseEditBase from './views/course/editBase.vue'
import CourseEditDetail from './views/course/editDetail.vue'
import CourseIntro from './views/course/intro.vue'
import GroupList from './views/group/index.vue'
import GroupStudents from './views/group/students.vue'
import Poster from './views/poster/index.vue'
import Account from './views/account/index.vue'

Vue.use(Router)

export default new Router({
    mode: 'history',
    base: process.env.BASE_URL,
    routes: [
        { 
            path: '/login', 
            name: 'login', 
            component: Login 
        },
        { 
            path: '/404', 
            name: 'not-found',
            component: NotFound 
        },
        {
            path: '/',
            redirect: '/course',
        },
        {
            path: '/course',
            component: Layout,
            name: 'course',
            redirect: '/course/list',
            meta: { title: '课程管理' },
            children: [{
                path: 'list',
                name: 'course-list',
                component: CourseList,
                meta: { title: '课程列表'}
            },{
                path: 'edit/base',
                name: 'course-create-base',
                component: CourseEditBase,
                meta: { title: '新建课程'}
            },{
                path: 'edit/base/:id',
                name: 'course-edit-base',
                component: CourseEditBase,
                meta: { title: '课程编辑'}
            },{
                path: 'edit/detail',
                name: 'course-create-detail',
                component: CourseEditDetail,
                meta: { title: '新建课程'}
            },{
                path: 'edit/detail/:id',
                name: 'course-edit-detail',
                component: CourseEditDetail,
                meta: { title: '课程编辑'}
            }, {
                path: 'edit/intro/:id',
                name: 'course-intro',
                component: CourseIntro,
                meta: { title: '课程素材'}
            }]
        }, {
            path: '/group',
            component: Layout,
            name: 'group',
            redirect: '/group/list',
            meta: { title: '群主'},
            children: [
                {
                    path: 'list',
                    name: 'group-list',
                    meta: { title: '群主列表'},
                    component: GroupList
                }, {
                    path: 'students/:id',
                    name: 'group-students',
                    meta: { title: '群主学员'},
                    component: GroupStudents
                }, 
            ]
        }, {
            path: '/poster',
            component: Layout,
            // name: 'poster',
            redirect: '/poster/list',
            // meta: { title: '海报管理'},
            children: [
                {
                    path: 'list',
                    name: 'poster-list',
                    meta: { title: '海报管理'},
                    component: Poster
                }
            ]
        }, {
            path: '/account',
            component: Layout,
            redirect: '/account/list',
            children: [
                {
                    path: 'list',
                    name: 'account-list',
                    meta: { title: '账号管理'},
                    component: Account
                }
            ]
        },
        { path: '*', redirect: '/404' }
    ]
})